'''
Created on Aug 23, 2012

@author: bbg
'''

import dbwrapper
from dbwrapper.company_management.cdkey import Cdkey
 
def CdkeyTest():
    dbsession = dbwrapper.MySqlSession()
    
    newCdkey = Cdkey()
    newCdkey.company_id = 1
    newCdkey.expire_time = "0000-00-00 00:00:00"
    newCdkey.valid_time = "0000-00-00 00:00:00"
    newCdkey.shop_id = 1
    newCdkey.state = 0
    newCdkey.uuid = 'wwww-wwww-xxxx'
    newCdkey.cdkey = 'abcdefg'
    
    dbsession.add(newCdkey)
    dbsession.commit()
    
    queryCdkeys = dbsession.query(Cdkey).filter(Cdkey.company_id == 1)
    
    dbsession.commit()
    print queryCdkeys.first().uuid
    
    dbsession.close()
    
    
if __name__ == "__main__":
    CdkeyTest()